import { Component, PropsWithChildren } from 'react'
import { View, Text, Image } from '@tarojs/components'
import { AtIcon } from "taro-ui"
import { getCollection } from '../../api/home'
import './index.scss'
import Taro from '@tarojs/taro'

export default class Index extends Component<PropsWithChildren> {
  state: any
  constructor(props) {
    super(props)
    this.state = {
      collectList: []
    }
  }
  componentWillMount() { }

  componentDidMount() {
    this.getCollectList()
  }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }
  getCollectList() {
    getCollection().then((res) => {
      this.setState({
        collectList: res.data.data
      })
    })
  }
  onClick() {
    Taro.navigateBack()
  }
  render() {
    return (
      <View className='index'>
        <View className='nav-bar-box'>
          <View className='status-bar'></View>
          <View className='title-bar'>
            <AtIcon onClick={this.onClick.bind(this)} className='icon' value='chevron-left' size='24' color='#fff'></AtIcon>
            <Text className='tit'>收藏</Text>
          </View>
        </View>
        <View className='message'>
          {
            this.state.collectList?.map((item: any, index: number) => {
              return <View className='cardList' key={index}>
              <Image src={item.img} />
              <View className='mes'>
                <View className='tit'>{item.title}</View>
                <View>{item.address}</View>
                <View className='mian'>{item.price}</View>
                <View className='area'>{item.area}</View>
              </View>
            </View>
            })
          }
        </View>
      </View >
    )
  }
}
